<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>预订单列表</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/animate.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/style.min.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
    	#queryorderForm label{padding-left:0; padding-right:0;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight" >
    <!-- Panel Other -->
    <div class="ibox float-e-margins" style="background:#fff;">
        <ul id="myTab" class="nav nav-tabs">
		    <li><a href="#allAdvanceOrder" data-toggle="tab">未支付订单</a></li>
		    <li><a href="#salesman" data-toggle="tab">派单给业务员</a></li>
		    <li><a href="#driver" data-toggle="tab">派单给司机</a></li>
		</ul>
		<div id="myTabContent" class="tab-content">
		    <div class="tab-pane" id="salesman">
		        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="example-wrap">
                        <!-- start toolbar -->
                        <div class="col-sm-12">
                            <form class="form-horizontal" role="form" id="querySalForm" autocomplete="off">
                                <div class="row">
                                 	<div class="col-sm-3 col-lg-3">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">预约单编号</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="预约单编号"  id="sorderNum" name="orderNum" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-3 col-lg-3">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">搬出人姓名</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="搬出人姓名"  id="sownerName" name="ownerName" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-3 col-lg-3">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">搬入人姓名</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="搬入人姓名"  id="srOwnerName" name="rOwnerName" value="">
                                            </div>
                                        </div>
                                    </div>
                                   
                                    <div class="col-sm-3 col-lg-3" style="padding:0;">
                                    	<button type="button" class="btn btn-primary" id="queryOrderBtn">
                                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查询
                                        </button>
                                        <button type="button" class="btn btn-info" onclick="salesmanReload()" id="salesmanReloadBtn">	<!-- location.reload(); -->
                                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 刷新
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- end toolbar -->
                        <div class="example">
                            <table id="salesmanOrderTab" class="table" data-click-to-select="true" data-mobile-responsive="true">
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
	 	</div>
		 <div class="tab-pane fade" id="driver">
	    	<div class="ibox-content">
	            <div class="row row-lg">
	                <div class="col-sm-12">
	                    <div class="example-wrap">
	                        <!-- start toolbar -->
	                        <div class="col-sm-12">
	                            <form class="form-horizontal" role="form" id="queryDriForm" autocomplete="off">
	                                <div class="row">
	                                    <div class="col-sm-3 col-lg-3">
	                                        <button type="button" class="btn btn-info" onclick="driverRolad()" id="driverReloadBtn">
	                                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 刷新
	                                        </button>
	                                    </div>
	                                </div>
	                            </form>
	                        </div>
	                        <!-- end toolbar -->
	                        <div class="example">
			                   <table id="driverOrderTab" class="table" data-click-to-select="true" data-mobile-responsive="true">
			                   </table>
			               </div>
	                    </div>
	                </div>
	            </div>
	        </div>
		    </div>
		    <div class="tab-pane fade" id="allAdvanceOrder">
		    	<div class="ibox-content">
		            <div class="row row-lg">
		                <div class="col-sm-12">
		                    <div class="example-wrap">
		                        <!-- start toolbar -->
		                        <div class="col-sm-12">
		                            <form class="form-horizontal" role="form" id="queryAllAdvanceForm" autocomplete="off">
		                                <div class="row">
		                                 	<div class="col-sm-3 col-lg-3">
		                                        <div class="form-group">
		                                            <label class="col-sm-4 control-label">预约单编号</label>
		                                            <div class="col-sm-8">
		                                                <input type="text" class="form-control" placeholder="预约单编号"  id="aorderNum" name="orderNum">
		                                            </div>
		                                        </div>
		                                    </div>
		                                     <div class="col-sm-3 col-lg-3">
		                                        <div class="form-group">
		                                            <label class="col-sm-4 control-label">状态</label>
		                                            <div class="col-sm-8">
		                                                <select id="aorderState" name="orderState" class="form-control">
		                                                    <option value="">选择当前状态</option>
		                                                    <option value="0">预约状态</option>
		                                                    <option value="1">业务员接单</option>
		                                                    <option value="2">上门确认</option>
		                                                    <option value="3">司机接单</option>
		                                                    <option value="4">司机接货</option>
		                                                    <option value="5">司机送达</option>
		                                                    <option value="6">人工确认</option>
		                                                    <option value="-1">异常单</option>
		                                                </select>
		                                            </div>
		                                        </div>
		                                    </div>
		                                    <div class="col-sm-3 col-lg-3">
		                                        <div class="form-group">
		                                            <label class="col-sm-4 control-label">发件人姓名</label>
		                                            <div class="col-sm-8">
		                                                <input type="text" class="form-control" placeholder="发件人姓名"  id="aownerName" name="ownerName">
		                                            </div>
		                                        </div>
		                                    </div>
		                                    <div class="col-sm-3 col-lg-3">
		                                        <div class="form-group">
		                                            <label class="col-sm-4 control-label">收件人姓名</label>
		                                            <div class="col-sm-8">
		                                                <input type="text" class="form-control" placeholder="收件人姓名"  id="arOwnerName" name="rOwnerName">
		                                            </div>
		                                        </div>
		                                    </div>
		                                    <div class="col-sm-3 col-lg-3">
		                                        <div class="form-group">
		                                            <label class="col-sm-4 control-label">货物名</label>
		                                            <div class="col-sm-8">
		                                                <input type="text" class="form-control" placeholder="货物名"  id="acargoName" name="cargoName">
		                                            </div>
		                                        </div>
		                                    </div>
		                                    <div class="col-sm-3 col-lg-3">
		                                        <div class="form-group">
		                                            <label class="col-sm-4 control-label">开始时间</label>
		                                            <div class="col-sm-8">
		                                                <input type="text" class="form-control layer-date" placeholder="开始时间"  id="astartDate" name="startDate">
		                                            </div>
		                                        </div>
		                                    </div>
		                                    <div class="col-sm-3 col-lg-3">
		                                        <div class="form-group">
		                                            <label class="col-sm-4 control-label">结束时间</label>
		                                            <div class="col-sm-8">
		                                                <input type="text" class="form-control layer-date" placeholder="结束时间"  id="aendDate" name="endDate">
		                                            </div>
		                                        </div>
		                                    </div>
		                                    <div class="col-sm-3 col-lg-3">
		                                    	<button type="button" class="btn btn-primary" id="queryAdvanceOrderBtn">
		                                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查询
		                                        </button>
		                                        <button type="button" class="btn btn-info" onclick="alladvanceReload()" id="advancReloadBtn">
		                                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 刷新
		                                        </button>
		                                    </div>
		                                </div>
		                            </form>
		                        </div>
		                        <!-- end toolbar -->
		                        <div class="example">
		                            <table id="advanceOrderTab" class="table" data-click-to-select="true" data-mobile-responsive="true">
		                            </table>
		                        </div>
		                    </div>
		                </div>
		            </div>
		        </div>
		    </div>
		</div>
    </div>
</div>
<!-- End Panel Other -->
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/layer/layer.min.js"></script>
<script src="${pageContext.request.contextPath}/laydate/laydate.js"></script>
<script src="${pageContext.request.contextPath}/js/public/ttbj-core.js"></script>
<script type="text/javascript" src="http://cdn.bootcss.com/sockjs-client/1.1.1/sockjs.js"></script>	
<script type="text/javascript" src="https://cdn.bootcss.com/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js"></script>

<script type="text/javascript">
var $salesmanOrderTable = $("#salesmanOrderTab");
var $driverOrderTable = $("#driverOrderTab");
var $advanceOrderTable = $("#advanceOrderTab");	//未支付的订单

$(function () {
	<shiro:hasPermission name="advance:order">
		var host = window.location.host;
		if('WebSocket' in window){
			websocket = new ReconnectingWebSocket("ws://" + host + '${pageContext.request.contextPath}' + "/push_msg.htm", null, {debug:true,maxReconnectAttempts:4});
			//websocket = new WebSocket("ws://"+ host +"/ttbj-web-backstage/push_msg.htm");
		}else if('MozWebSocket' in window){
			websocket = new MozwebSocket("ws://" + host + '${pageContext.request.contextPath}' + "/push_msg.htm");
		}else{
			websocket = new SockJS("http://" + host + '${pageContext.request.contextPath}' + "/sockjs/push_msg.htm");
		}
		//建立连接
		websocket.onopen = function(envt){console.log("websocket 已连接");};
		//接收和发送消息
		websocket.onmessage = function(envt){
			layer.open({	//消息弹出层
				type: 1,
	            title: '消息',
	            content: '有新的预订单',
	            offset: 'rb',
	            skin: 'layui-layer-demo',
	            area: ['200px', '150px'],
	            btn: ['确定'],
	            shade: false,
	            yes: function(index, layero){	//点击确定后的回调函数
	            	layer.close(index);	//关闭消息层
	            	$('#myTab a[href="#salesman"]').click();	//点击分配给业务员的tab
	            },
	            success: function(layero, index){}
	        });
		};
		websocket.onerror = function(evnt) {console.log("websocket错误");};
		websocket.onclose = function(evnt) {console.log("websocket关闭");};
		window.close = function(){websocket.onclose();}
	</shiro:hasPermission>
	
	//给两个tab绑定click事件
	$('#myTab a').click(function(e){
		e.preventDefault();	//阻止a链接的跳转行为
		var whichOne = $(this).attr('href');	//获取是点击的哪个
		if(whichOne == "#salesman"){
			initSalesmanTable();
		}else if(whichOne == "#driver") {
			initDriverTable();
		}else {
			initadvanceOrderTable();
		}
	});
	
	//预订单分配给业务员的条件查询
    $("#queryOrderBtn").click(function () {
    	$salesmanOrderTable.bootstrapTable('refresh');	//使用post提交
    });
  	//未支付订单的条件查询
    $("#queryAdvanceOrderBtn").click(function () {
    	$advanceOrderTable.bootstrapTable('refresh');	 //使用post提交
    });
	//时间控件
	$.initDateScope('astartDate','aendDate',false);
	//当页面加载完成后触发（要先绑定click事件，然后再触发，顺序不能乱）
	$('#myTab a[href="#allAdvanceOrder"]').trigger('click');
});

//点击未支付订单的刷新按钮
function alladvanceReload(){
	$('#myTab a[href="#allAdvanceOrder"]').tab('show');
	//清空表单里的数据
	clearFormData('#queryAllAdvanceForm');
	$advanceOrderTable.bootstrapTable('refresh', {url: '../order/getAdvanceOrderInfoByPage.htm'});
}

//点击派单给业务员的刷新按钮
function salesmanReload(){
	$('#myTab a[href="#salesman"]').tab('show');
	//清空表单里的数据
	clearFormData('#querySalForm');
	$salesmanOrderTable.bootstrapTable('refresh', {url: '../order/getAdvanceSalOrderInfoByPage.htm'});
}

//点击派单给司机的刷新按钮
function driverRolad(){
	$('#myTab a[href="#driver"]').tab('show');
	$driverOrderTable.bootstrapTable('refresh', {url: '../order/getAdvanceDriOrderInfoByPage.htm'});
}

//清空表单里的数据
function clearFormData(formId){
	$(':input', formId).not(':button,:submit,:reset,:hidden').val('').removeAttr('checked').removeAttr('selected');
}


function initSalesmanTable() {
	$salesmanOrderTable.bootstrapTable({
        dataType: "json",
        showColumns: true, 
        pagination: true, //分页
        striped: true,
        cache: false,	//是否使用缓存，默认是true
        pageSize: 10,
        pageNumber: 1,
        queryParamsType: 'limit',
        smartDisplay: true,
        sidePagination: "server",
        method: "post",	//使用post提交
        queryParams: queryParams,
        url: '../order/getAdvanceSalOrderInfoByPage.htm',
        contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
        columns: [
            {
                title: "序号",
                align: 'center',
                formatter:function(value,row,index){
                    return index + 1;
                }
            },
            {
                title: "预约单编号",
                field: "orderNum",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "状态",
                field: "orderState",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderState = "-";
                    if(row.orderState == 0){
                    	orderState = '预约状态';
                    }else if(row.orderState == 1){
                    	orderState ='业务员接单';
                    }else if(row.orderState == 2){
                    	orderState ='上门确认';
                    }
                    else if(row.orderState == 3){
                    	orderState ='司机接单';
                    }
                    else if(row.orderState == 4){
                    	orderState ='司机接货';
                    }
                    else if(row.orderState == 5){
                    	orderState ='司机送达';
                    }
                    else if(row.orderState == 6){
                    	orderState ='人工确认';
                    }
                    else if(row.orderState == -1){
                    	orderState ='异常单';
                    }
                    return orderState;
                }
            },
            {
                title: "备注",
                field: "orderNotes",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "预约时间",
                field: "orderPrearrangeTime",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "订单运费(元)",
                field: "orderCarriage",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "是否是搬运单",
                field: "orderIsMove",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderIsMove = "-";
                    if(row.orderIsMove == 0){
                    	orderIsMove = '搬运单';
                    }else if(row.orderIsMove == 1){
                    	orderIsMove ='同城配送单';
                    }
                    return orderIsMove;
                }
            },
            {
                title: "搬出人姓名",
                field: "ownerName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬出人电话",
                field: "ownerPhone",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬出人地址",
                field: "ownerAddr",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬入人姓名",
                field: "rOwnerName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬入人地址",
                field: "rOwnerAddr",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "微信昵称",
                field: "viewNickName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "操作",
                align: 'center',
                formatter: function (value, row, index) {
                    var a = '<shiro:hasPermission name="advance:order"> <button class="btn btn-xs btn-info" type="button" onclick="distributeSalesman(\'' + row.orderId + '\',\'' + row.orderNum + '\')"><i class="fa fa-edit"></i>业务员</button> </shiro:hasPermission>';
                    return a;
                }
            }
        ],
        onClickRow: function(row, $element, field){	//当点击某一行时，该行背景颜色改变
        	var trObj = $($element[0]);
        	var dataIndex = trObj.attr('data-index');
        	$("tr[data-index != '" + dataIndex + "']").removeAttr('style');
        	trObj.attr('style', 'background: #B4EEB4');
        }
    });
}

//分页参数，条件查询时的参数
function queryParams(queryParamsType){
	var temp = {
		limit: queryParamsType.limit,
		offset: queryParamsType.offset,
		orderNum: $.trim($('#sorderNum').val()),
		ownerName: $.trim($('#sownerName').val()),
		rOwnerName: $.trim($('#srOwnerName').val())
	};
	return temp;
}

//分配给司机的订单列表
function initDriverTable() {
	$driverOrderTable.bootstrapTable({
        dataType: "json",
        showColumns: true, 
        pagination: true, //分页
        striped: true,
        cache: false,	//是否使用缓存，默认是true
        pageSize: 10,
        pageNumber: 1,
        queryParamsType: 'limit',
        smartDisplay: true,
        sidePagination: "server",
        method: "post",	//使用post提交
        queryParams: queryParams,
        url: '../order/getAdvanceDriOrderInfoByPage.htm',
        contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
        columns: [
            {
                title: "序号",
                align: 'center',
                formatter:function(value,row,index){
                    return index + 1;
                }
            },
            {
                title: "预约单编号",
                field: "orderNum",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "状态",
                field: "orderState",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderState = "-";
                    if(row.orderState == 0){
                    	orderState = '预约状态';
                    }else if(row.orderState == 1){
                    	orderState ='业务员接单';
                    }else if(row.orderState == 2){
                    	orderState ='上门确认';
                    }
                    else if(row.orderState == 3){
                    	orderState ='司机接单';
                    }
                    else if(row.orderState == 4){
                    	orderState ='司机接货';
                    }
                    else if(row.orderState == 5){
                    	orderState ='司机送达';
                    }
                    else if(row.orderState == 6){
                    	orderState ='人工确认';
                    }
                    else if(row.orderState == -1){
                    	orderState ='异常单';
                    }
                    return orderState;
                }
            },
            {
                title: "备注",
                field: "orderNotes",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "预约时间",
                field: "orderPrearrangeTime",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "订单运费(元)",
                field: "orderCarriage",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "是否是搬运单",
                field: "orderIsMove",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderIsMove = "-";
                    if(row.orderIsMove == 0){
                    	orderIsMove = '搬运单';
                    }else if(row.orderIsMove == 1){
                    	orderIsMove ='同城配送单';
                    }
                    return orderIsMove;
                }
            },
            {
                title: "搬出人姓名",
                field: "ownerName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬出人电话",
                field: "ownerPhone",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬出人地址",
                field: "ownerAddr",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬入人姓名",
                field: "rOwnerName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬入人地址",
                field: "rOwnerAddr",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "微信昵称",
                field: "viewNickName",
                align: 'center',
                valign: 'middle'
            },{
            	title: "业务员",
            	field: "salesmanName",
            	align: "center",
            	valign: "middle"
            },
            {
            	title: "需要司机数量",
            	align: "center",
            	formatter: function(value, row, index){
            		var orderDriverRequire = row.orderDriverRequire;
            		var orderDriverAlready = row.orderDriverAlready;
            		var num = orderDriverRequire-orderDriverAlready;
            		return '<span style="color:#ed5565;">' + num + '</span>';
            	}
            },
            {
                title: "操作",
                align: 'center',
                formatter: function (value, row, index) {
                    var b = '<shiro:hasPermission name="advance:order"> <button class="btn btn-xs btn-info" type="button" onclick="distributeDriver(\'' + row.orderId + '\',\'' + row.orderDriverRequire + '\',\'' + row.orderDriverAlready + '\')"><i class="fa fa-edit"></i>司机</button> </shiro:hasPermission>';
                    return b;
                }
            }
        ],
        onClickRow: function(row, $element, field){	//当点击某一行时，该行背景颜色改变
        	var trObj = $($element[0]);
        	var dataIndex = trObj.attr('data-index');
        	$("tr[data-index != '" + dataIndex + "']").removeAttr('style');
        	trObj.attr('style', 'background: #B4EEB4');
        }
    });
}

//未支付的订单列表
function initadvanceOrderTable() {
	$advanceOrderTable.bootstrapTable({
        dataType: "json",
        showColumns: true, 
        pagination: true, //分页
        striped: true,
        cache: false,	//是否使用缓存，默认是true
        pageSize: 10,
        pageNumber: 1,
        queryParamsType: 'limit',
        smartDisplay: true,
        sidePagination: "server",
        method: "post",	//使用post提交
        queryParams: queryAdvanceParams,
        url: '../order/getAdvanceOrderInfoByPage.htm',
        contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
        columns: [
            {
                title: "序号",
                align: 'center',
                formatter:function(value,row,index){
                    return index + 1;
                }
            },
            {
                title: "预约单编号",
                field: "orderNum",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "状态",
                field: "orderState",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderState = "-";
                    if(row.orderState == 0){
                    	orderState = '预约状态';
                    }else if(row.orderState == 1){
                    	orderState ='业务员接单';
                    }else if(row.orderState == 2){
                    	orderState ='上门确认';
                    }else if(row.orderState == 3){
                    	orderState ='司机接单';
                    }else if(row.orderState == 4){
                    	orderState ='司机接货';
                    }else if(row.orderState == 5){
                    	orderState ='司机送达';
                    }else if(row.orderState == 6){
                    	orderState ='人工确认';
                    }else if(row.orderState == -1){
                    	orderState ='异常单';
                    }
                    return orderState;
                }
            },
            {
                title: "支付状态",
                field: "orderPayState",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderPayState = "-";
                    if(row.orderPayState == 0){
                    	orderPayState = '<span style="color:green;">已支付</span>';
                    }else if(row.orderState == 1){
                    	orderPayState ='<span style="color:red;">未支付</span>';
                    }else {
                    	orderPayState = '<span style="color:DarkRed;">暂不能支付</span>';
                    }
                    return orderPayState;
                }
            },
            {
                title: "订单生成时间",
                field: "orderInsDate",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "是否搬运",
                field: "orderToCarry",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderToCarry = "-";
                    if(row.orderToCarry == 0){
                    	orderToCarry = '<span style="color:green;">搬运</span>';
                    }else if(row.orderToCarry == 1){
                    	orderToCarry ='<span style="color:red;">无需搬运</span>';
                    }
                    return orderToCarry;
                }
            },
            {
                title: "是否打包",
                field: "orderToPack",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderToCarry = "-";
                    if(row.orderToCarry == 0){
                    	orderToCarry = '<span style="color:green;">打包</span>';
                    }else if(row.orderToCarry == 1){
                    	orderToCarry ='<span style="color:red;">无需打包</span>';
                    }
                    return orderToCarry;
                }
            },
            {
                title: "楼层数",
                field: "orderFloorNum",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "集装箱数",
                field: "orderBoxNum",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "订单类型",
                field: "orderIsMove",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var orderIsMove = "-";
                    if(row.orderIsMove == 0){
                    	orderIsMove = '搬运单';
                    }else if(row.orderIsMove == 1){
                    	orderIsMove ='同城配送单';
                    }
                    return orderIsMove;
                }
            },
            {
                title: "全部费用(元)",
                field: "orderAllPay",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "预约时间",
                field: "orderPrearrangeTime",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "订单运费(元)",
                field: "orderCarriage",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "订单距离",
                field: "orderDistance",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "打包费用(元)",
                field: "orderPackPay",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "搬家费用(元)",
                field: "orderMovePay",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "发件人姓名",
                field: "ownerName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "收件人姓名",
                field: "rOwnerName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "司机",
                field: "driverRealName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "货物名",
                field: "cargoName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "微信昵称",
                field: "viewNickName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "公司名",
                field: "comnumName",
                align: 'center',
                valign: 'middle'
            }
        ],
        onClickRow: function(row, $element, field){	//当点击某一行时，该行背景颜色改变
        	var trObj = $($element[0]);
        	var dataIndex = trObj.attr('data-index');
        	$("tr[data-index != '" + dataIndex + "']").removeAttr('style');
        	trObj.attr('style', 'background: #B4EEB4');
        }
    });
}

//分页参数，条件查询时的参数
function queryAdvanceParams(queryParamsType){
	var temp = {
		limit: queryParamsType.limit,   //页面大小
		offset: queryParamsType.offset,  //页码
		orderNum: $.trim($('#aorderNum').val()),
		orderState: $.trim($('#aorderState').val()),
		ownerName: $.trim($('#aownerName').val()),
		rOwnerName: $.trim($('#arOwnerName').val()),
		cargoName: $.trim($('#acargoName').val()),
		endDate: $.trim($('#aendDate').val()),
		startDate: $.trim($('#astartDate').val())
	};
	return temp;
}


//分配业务员
function distributeSalesman(orderId){
    var index = layer.open({
        type: 2,
        title: '分配业务员',
        maxmin: false,
        shadeClose: false, //点击遮罩关闭层
        area : ['400px' , '400px'],
        content: '../order/distribute_salesman.htm?id=' + orderId,
        success: function(layero, index){
        }
    });
}

//分配司机
function distributeDriver(orderId, require, already){
    var index = layer.open({
        type: 2,
        title: '分配司机',
        maxmin: false,
        shadeClose: false, //点击遮罩关闭层
        area : ['400px' , '500px'],
        content: '../order/distribute_driver.htm?id=' + orderId + "&require=" + require + "&already=" + already,
        success: function(layero, index){
        }
    });
}
</script>
</body>
</html>
